package day3.demo7_syncronize;

public class Sell implements Runnable{

    static int sum=1000;
    @Override
    public void run() {
        while (sum>0){
            synchronized (this)  {
                if(sum<=0){
                    return;
                }
                System.out.println(Thread.currentThread().getName() + "卖出第" + sum + "张票");
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                sum--;
            }
        }
    }
}
